import React from 'react';
import { injectIntl } from 'react-intl';
import { withRouter } from 'react-router-dom';
import Grid from '../../components/table/grid';

@withRouter
class chargePermit extends React.Component{
    constructor(props){
        super(props);
        this.state={
            refresh:0,
            params:{
                stubId:this.props.location.state
            }
        }
        this.columns=[
            {
                title: '项目',
                dataIndex: 'name',
                key: 'name',
            },
            {
                title: '设备端名单',
                dataIndex: 'equipName',
                key: 'equipName',
            },
            {
                title: '平台名单',
                dataIndex: 'platformName',
                key: 'platformName',
            }
        ]
    }

    transformData=(data)=>{
        debugger;
        return [{name:'最后变更时间',equipName:data.stubConfigModifyTime,platformName:data.platformConfigModifyTime},
        {name:'vin',equipName:data.stubVin||`123123323,asdasd,asdasdasd,asdasdasd,asdasdasd,asdasdsa,fdgdfgfdg,dfgfdgdfg,dfgdfgdfg,dfgdfgdfg,dfgdfgdgf,dfgdfgdfg,`,platformName:data.platformVin},
        {name:'电卡',equipName:data.stubCard,platformName:data.platformCard}]
    }

    render(){
        if(!this.props.location.state){
            this.props.history.go(-1);
            return null;
        }
        return(
            <div>
                <Grid transformData={this.transformData} refresh={this.state.refresh} params={this.state.params}
                      columns={this.columns} url="/api/stub/config/detail"/>
            </div>
        )
    }
}

export default injectIntl(chargePermit)

